#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <lobi/bmesh.h>

int main(int argc,char* argv[])
{
	FILE* ifp;
	char* data;
	struct bmesh_t* mesh;
	
	if (argc != 2) {
		printf("Usage: %s MESHFILE\n",argv[0]);
		return 1;
	}
	if ((ifp=fopen(argv[1],"rb")) == NULL) {
		printf("%s: Cannot open file for reading\n",argv[1]);
		return 1;
	}

	/* read the data into memory */
	{
		unsigned int length;
		
		fseek(ifp,0,SEEK_END);
		length = ftell(ifp);
		data = malloc(length);
		rewind(ifp);
		fread(data,1,length,ifp);
	}

	fclose(ifp);

	/* convert file data into bmesh_t struct */
	if ((mesh=bmesh_sread(data)) == NULL) {
		printf("Error reading mesh file\n");
		return 1;
	}

	printf("File parsed OK.\n");

	bmesh_free(mesh);
	
	return 0;
}




